//
// DotNetNuke - http://www.dotnetnuke.com
// Copyright (c) 2002-2010
// by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions 
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
//

using System;
using System.Collections;
namespace DotNetNuke.ComponentModel
{
	public abstract class AbstractContainer : IContainer
	{
		public abstract string Name { get; }
		public abstract object GetComponent(string name);
		public abstract object GetComponent(string name, System.Type contractType);
		public abstract object GetComponent(System.Type contractType);
		public virtual TContract GetComponent<TContract>()
		{
			return (TContract)GetComponent(typeof(TContract));
		}
		public virtual TContract GetComponent<TContract>(string name)
		{
			return (TContract)GetComponent(name, typeof(TContract));
		}
		public abstract string[] GetComponentList(Type contractType);
		public virtual string[] GetComponentList<TContract>()
		{
			return GetComponentList(typeof(TContract));
		}
		public abstract IDictionary GetComponentSettings(string name);
		public virtual IDictionary GetComponentSettings(System.Type component)
		{
			return GetComponentSettings(component.FullName);
		}
		public virtual IDictionary GetCustomDependencies<TComponent>()
		{
			return GetComponentSettings(typeof(TComponent).FullName);
		}
		public IDictionary GetComponentSettings<TComponent>()
		{
			return GetComponentSettings(typeof(TComponent).FullName);
		}
		public abstract void RegisterComponent(string name, System.Type contractType, System.Type componentType, ComponentLifeStyleType lifestyle);
		public virtual void RegisterComponent(string name, System.Type contractType, System.Type componentType)
		{
			RegisterComponent(name, contractType, componentType, ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent(string name, System.Type componentType)
		{
			RegisterComponent(name, componentType, componentType, ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent(System.Type contractType, System.Type componentType)
		{
			RegisterComponent(componentType.FullName, contractType, componentType, ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent(System.Type contractType, System.Type componentType, ComponentLifeStyleType lifestyle)
		{
			RegisterComponent(componentType.FullName, contractType, componentType, lifestyle);
		}
		public virtual void RegisterComponent(System.Type componentType)
		{
			RegisterComponent(componentType.FullName, componentType, componentType, ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent<TComponent>() where TComponent : class
		{
			RegisterComponent(typeof(TComponent));
		}
		public virtual void RegisterComponent<TComponent>(string name) where TComponent : class
		{
			RegisterComponent(name, typeof(TComponent), typeof(TComponent), ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent<TComponent>(string name, ComponentLifeStyleType lifestyle) where TComponent : class
		{
			RegisterComponent(name, typeof(TComponent), typeof(TComponent), lifestyle);
		}
		public virtual void RegisterComponent<TContract, TComponent>() where TComponent : class
		{
			RegisterComponent(typeof(TContract), typeof(TComponent));
		}
		public virtual void RegisterComponent<TContract, TComponent>(string name) where TComponent : class
		{
			RegisterComponent(name, typeof(TContract), typeof(TComponent), ComponentLifeStyleType.Singleton);
		}
		public virtual void RegisterComponent<TContract, TComponent>(string name, ComponentLifeStyleType lifestyle) where TComponent : class
		{
			RegisterComponent(name, typeof(TContract), typeof(TComponent), lifestyle);
		}
		public abstract void RegisterComponentSettings(string name, System.Collections.IDictionary dependencies);
		public virtual void RegisterComponentSettings(System.Type component, System.Collections.IDictionary dependencies)
		{
			RegisterComponentSettings(component.FullName, dependencies);
		}
		public virtual void RegisterComponentSettings<TComponent>(System.Collections.IDictionary dependencies)
		{
			RegisterComponentSettings(typeof(TComponent).FullName, dependencies);
		}
		public abstract void RegisterComponentInstance(string name, System.Type contractType, object instance);
		public void RegisterComponentInstance(string name, object instance)
		{
			RegisterComponentInstance(name, instance.GetType(), instance);
		}
		public void RegisterComponentInstance<TContract>(object instance)
		{
			RegisterComponentInstance(instance.GetType().FullName, typeof(TContract), instance);
		}
		public void RegisterComponentInstance<TContract>(string name, object instance)
		{
			RegisterComponentInstance(name, typeof(TContract), instance);
		}
	}
}
